package com.example.combination;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private ImageView iv3;
    private ConstraintLayout level3;
    private ImageView iv2;
    private ConstraintLayout level2;
    private ImageView iv1;
    private ConstraintLayout level1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        iv3 = (ImageView) findViewById(R.id.iv3);
        level3 = (ConstraintLayout) findViewById(R.id.level3);
        iv2 = (ImageView) findViewById(R.id.iv2);
        level2 = (ConstraintLayout) findViewById(R.id.level2);
        iv1 = (ImageView) findViewById(R.id.iv1);
        level1 = (ConstraintLayout) findViewById(R.id.level1);
        iv1.setOnClickListener(this);
        iv2.setOnClickListener(this);
        iv3.setOnClickListener(this);
    }
    boolean isShow1=false;
    boolean isShow2=true;
    boolean isShow3=true;
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv1:
                //level2，如果显示就隐藏
                if (isShow2) {
                    isShow2=false;
                    Tool2.hideView(level2);
                    if (isShow3) {
                        isShow3=false;
                        Tool2.hideView(level3,200);
                    }
                }else {
                    isShow2=true;
                    Tool2.show(level2);
                }
                break;
            case R.id.iv2:
                if (isShow3) {
                    isShow3=false;
                    Tool2.hideView(level3);
                }else {
                    Tool2.show(level3);
                    isShow3=true;
                }
                break;
            case R.id.iv3:
                break;
        }
    }
}
